<template>
	<div>
		<el-dialog title="选择文件" :visible.sync="dialogVisible" width="60%" class="uploaddialog">
			<div>
				<div class="uploadtop">
					<span>文件({{total}})</span>
				</div>
				<uploadbottomfiles ref="uploadbottomfiles" v-on:updateFilesTotal="updateFilesTotal"></uploadbottomfiles>
			</div>
			<div slot="footer" class="dialog-footer">
				<el-button @click="dialogVisible = false">取 消</el-button>
				<el-button type="primary" @click="condialogVisible">确 定</el-button>
			</div>
		</el-dialog>
	</div>
</template>

<script>
	import uploadbottomfiles from '@/components/common/uploadbottomfiles.vue';
	export default {
		components: {
			uploadbottomfiles
		},
		data() {
			return {
				dialogVisible: false,
				total: 0,
				isone: true
			}
		},
		methods: {
			condialogVisible() { //确认按钮
				let data = this.$refs.uploadbottomfiles.multipleSelection;
				if (this.isone) {
					if (data.length != 1) {
						this.$message.error('只能选择1个文件！');
						return;
					}
					// //this.$parent.$parent.nowitem.dantuimg.src=this.multipleSelection[0].src;
					this.$emit('childByFilesValue', data[0]);
				} else {
					this.$emit('childByFilesValue', data);
				}
				this.dialogVisible = false;
			},
			updateFilesTotal: function(childValue) {
				this.total = childValue;
			}
		}
	}
</script>

<style lang="scss">
	.uploaddialog {
		.el-tree-node:focus>.el-tree-node__content {
			background-color: #409EFF;
			color: white;
		}

		.el-tree--highlight-current .el-tree-node.is-current>.el-tree-node__content {
			background-color: #409EFF;
			color: white;
		}

		.uploadtop {
			border-top: 1px solid #eee;
			border-bottom: 1px solid #eee;
			line-height: 50px;
			margin-bottom: 10px;

			span {
				padding-left: 20px;
				padding-right: 10px;
				display: inline-block;
				line-height: 50px;

			}
		}

	}
</style>
